package com.ruoyi.platform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.platform.domain.TbPlatform;
import com.ruoyi.platform.service.ITbPlatformService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 平台更新Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/platform")
public class TbPlatformController extends BaseController
{
    @Autowired
    private ITbPlatformService tbPlatformService;

    /**
     * 查询平台更新列表
     */
    //@RequiresPermissions("platform:platform:list")
    @GetMapping("/list")
    public TableDataInfo list(TbPlatform tbPlatform)
    {
        startPage();
        List<TbPlatform> list = tbPlatformService.selectTbPlatformList(tbPlatform);
        return getDataTable(list);
    }

    /**
     * 导出平台更新列表
     */
    //@RequiresPermissions("platform:platform:export")
    @Log(title = "平台更新", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbPlatform tbPlatform)
    {
        List<TbPlatform> list = tbPlatformService.selectTbPlatformList(tbPlatform);
        ExcelUtil<TbPlatform> util = new ExcelUtil<TbPlatform>(TbPlatform.class);
        util.exportExcel(response, list, "平台更新数据");
    }

    /**
     * 获取平台更新详细信息
     */
    //@RequiresPermissions("platform:platform:query")
    @GetMapping(value = "/{platformId}")
    public AjaxResult getInfo(@PathVariable("platformId") Long platformId)
    {
        return success(tbPlatformService.selectTbPlatformByPlatformId(platformId));
    }

    /**
     * 新增平台更新
     */
    //@RequiresPermissions("platform:platform:add")
    @Log(title = "平台更新", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbPlatform tbPlatform)
    {
        return toAjax(tbPlatformService.insertTbPlatform(tbPlatform));
    }

    /**
     * 修改平台更新
     */
    //@RequiresPermissions("platform:platform:edit")
    @Log(title = "平台更新", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbPlatform tbPlatform)
    {
        return toAjax(tbPlatformService.updateTbPlatform(tbPlatform));
    }

    /**
     * 删除平台更新
     */
    //@RequiresPermissions("platform:platform:remove")
    @Log(title = "平台更新", businessType = BusinessType.DELETE)
	@DeleteMapping("/{platformIds}")
    public AjaxResult remove(@PathVariable Long[] platformIds)
    {
        return toAjax(tbPlatformService.deleteTbPlatformByPlatformIds(platformIds));
    }
}
